package com.sumainfor.pc.gmio.controller.director;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.PageUtils;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.gmio.service.DiWithdrawalApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 *退租
 */
@RestController
@RequestMapping("/tenant/key/director/DiWxWithdrawalApply")
public class DiWxWithdrawalApplyController implements Serializable {
    @Autowired
    private DiWithdrawalApplyService diWithdrawalApplyService;
    /**
     *退租申请
     */
    @PostMapping("/addDiWith")
    public JsonResult addDiWith(@RequestBody Map<String,Object>params){
        return diWithdrawalApplyService.addDiWith(params);
    }
    /**
     * 查询退租申请列表
     */
    @GetMapping("/getDiWithdrawalApplyList")
    public JsonResult getDiWithdrawalApplyList(@RequestParam Map<String,Object>params, Pager pager){
        JsonResult result=new JsonResult();
        pager.setPagerNecessary(params, pager);
        PageUtils pageUtils = new PageUtils();
        Integer cout=diWithdrawalApplyService.getDiWithdrawalApplyListCount(params);
        if(cout==0){
            return pageUtils.getJsonResult(new ArrayList<Map<String,Object>>(), params,cout);
        }
        List<Map<String,Object>> getCommunityList=diWithdrawalApplyService.getDiWithdrawalApplyList(params);
        result=pageUtils.getJsonResult(getCommunityList, params, cout);
        return result;
    }
    /**
     * 租客端查询是否发起过退租申请
     */
    @GetMapping("/getDiWithdrawalApplyCount")
    public JsonResult getDiWithdrawalApplyCount(@RequestParam Map<String,Object>params){
        return diWithdrawalApplyService.getDiWithdrawalApplyCount(params);
    }
    /**
     *租客取消退租申请
     */
    @PostMapping("/updateDilApply")
    public JsonResult updateDilApply(@RequestBody Map<String,Object>params){
        return diWithdrawalApplyService.updateDilApply(params);
    }
}
